home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byt0187a.arc
/
FREEDMAN.ARC
/
PAL1.BAS
next >
Wrap
BASIC Source File
|
1980-01-01
|
12KB
|
291 lines
10 REM DEFINE VARIABLEs
20 CLEAR
30 DEFINT C,F,H,N,O,T,W,X,Y,Z,L
40 DIM F(39,79),N2(24)
50 DEFSTR A,D,P
60 DIM A(15),P(25),N(12),N1(12)
70 X$=CHR$(32):A=STRING$(50," "):AT=A+" "
80 C=0:X=0:Y=0:Z=0:S$=""
90 REM ***********************************************************
100 REM *** INFORMATION ABOUT PALASM SPECEFICATION ***
110 REM ***********************************************************
115 PRINT"(c) Copyright 1983 Monolithic Memories Inc. All Rights Reserved"
116 PRINT
120 PRINT TAB(13)"PALASM-20/24 in Basic":PRINT
130 PRINT TAB(11)"Revision level 1.2"
140 PRINT TAB(11)"07/15/81 D. Jones"
150 PRINT TAB(11)"06/22/83 U. Mueller & C.B. Lee"
160 PRINT
170 PRINT"Note: When using the 20X- Pals in the series 24"
180 PRINT"family, the XOR operator ':+:' should start a new"
190 PRINT"line. Thus: /Q1 := A*B + C*D :+: E*F + G*H"
200 PRINT"is an error":PRINT
210 PRINT"It should read:"
220 PRINT" /Q1 := A*B + C*D or /Q1 := A*B"
230 PRINT" :+: E*F + G*H + C*D"
240 PRINT" :+: E*F"
250 PRINT"The second format is recommended + G*H"
260 PRINT"for ease of reading and commenting."
270 PRINT"Note also a space is required before and after"
280 PRINT"the '+' in the first format."
285 PRINT
290 PRINT"Press a key to continue..."
300 DUMMY$=INKEY$:IF DUMMY$="" THEN 300
310 FOR I=1 TO 23:PRINT:NEXT
320 PRINT"What is your input file name ?";
330 LINE INPUT F$:IF F$="" THEN 120:REM * GET FILENAME *
340 X=1:OPEN "I",1,F$:REM * X=NUMBER OF LINES READ IN *
350 FOR I=1 TO 10:PRINT:NEXT
360 PRINT" ASSEMBLING...PLEASE WAIT !!!"
370 PRINT:PRINT
380 REM **********************************************************
390 REM *** VERIFY PART NUMBER AND GET TYPE ***
400 REM **********************************************************
410 LINE INPUT #1,A:TY=0
415 IF A="" THEN 410
420 X=INSTR(A,"PAL")
430 OT$=MID$(A,X+5,1):P=MID$(A,X+6,2):NO=VAL(P)
440 PN=MID$(A,X,8):IF RIGHT$(PN,1)=" " THEN PN=LEFT$(PN,7)
450 P=LEFT$(PN,3):IF P<>"PAL" THEN GOTO 590 ELSE P=MID$(PN,4,5)
460 OPEN "I",2,"PALTABLE.DAT"
465 INPUT #2,TYPE$
470 IF TYPE$<>P THEN LINE INPUT #2,DUMMY$:GOTO 465
475 INPUT #2,TY,XM,YM,S,FCODE
485 FOR I=1 TO S
495 INPUT #2,N2(I)
505 NEXT I
515 FOR I=0 TO S-12
525 INPUT #2,N(I),N1(I)
535 NEXT I
540 FOR I=1 TO INT((S/2)-1)
545 INPUT #2,IX(I)
550 NEXT I
555 CLOSE 2
590 IF TY=0 THEN GOSUB 2020:PRINT"INVALID PART NUMBER":END
600 PRINT"PART NUMBER ... OK !!!"
605 GOSUB 3000
610 REM ************************************************************
620 REM *** VERIFY PIN LIST ***
630 REM ************************************************************
640 FOR I=1 TO 4:LINE INPUT #1,A:NEXT I
650 Y=1
660 A=A+" ":C=LEN(A):FOR X=1 TO C
670 P=MID$(A,X,1):IF P<>" " THEN P(Y)=P(Y)+P
680 IF P=" " AND P(Y)<>"" THEN Y=Y+1
690 NEXT:IF Y=S+2 THEN 710 ELSE IF Y<S+2 THEN LINE INPUT #1,A:GOTO 660
700 GOSUB 2020:PRINT"INVALID PIN LIST":END
710 W=(S+1)/2:IF P(W)="GND" THEN 730
720 PRINT"ERROR CORRECTED... PIN";W;" IS NOW `GND'":P(W)="GND"
730 W=S+1:IF P(W)="VCC" THEN 750
740 PRINT"ERROR CORRECTED... PIN";W;" IS NOW `VCC'":P(W)="VCC"
750 PRINT"PIN LIST ...... OK !!!"
780 REM ***********************************************************
790 REM *** FIND OUTPUT IN EQUATION ***
800 REM ***********************************************************
810 OU=0:IF TY>4 AND TY<9 THEN NO=8
820 IF TY=16 THEN NO=8 ELSE IF TY=15 THEN NO=10
830 LINE INPUT #1,A:IF EOF(1) THEN CLOSE:GOTO 2380
840 IF LEFT$(A,1)=";" OR INSTR(A,"=")=0 THEN 830
850 ZZ=INSTR(A,";"):IF ZZ<>0 THEN A=LEFT$(A,ZZ-1)
860 IF INSTR(A," ")=0 THEN 880
870 ZZ=INSTR(A," "):A=LEFT$(A,ZZ-1)+RIGHT$(A,LEN(A)-ZZ):GOTO 860
880 AA=A:FC=0:FS=0:FR=0:AT="":DL=")/ "
890 CE=INSTR(A,"="):IF CE=0 THEN 830
900 OU=OU+1:IF OU>NO THEN 1650
910 AL=LEFT$(A,CE-1):CT=LEN(A):CN=CE
920 CN=CN-1:IF CN=0 THEN GOTO 950
930 P=MID$(A,CN,1):IF P=" " THEN 920 ELSE IF P=":" THEN FR=1:GOTO 920
940 P=MID$(A,CN,1):IF INSTR(DL,P)=0 THEN AT=P+AT:CN=CN-1:IF CN<>0 THEN 940
950 IF INSTR(AT," ")<>0 THEN AT=LEFT$(AT,LEN(AT)-1):GOTO 950
960 FOR Z=12 TO S:IF AT=P(Z) OR P(Z)=("/"+AT) THEN GOSUB 1910:GOTO 990
970 IF AT=("/"+P(Z)) THEN GOSUB 1910:GOTO 990 ELSE NEXT
980 GOSUB 2020:PRINT"OUTPUT UNDEFINED BY PIN LIST":GOTO 1680
990 IF Y=0 THEN GOSUB 2020:PRINT"INVALID OUTPUT PIN":GOTO 1680
1000 IF Y>100 THEN FR=1:Y=Y-100 ELSE IF Y<0 THEN FC=1:Y=-Y ELSE FS=1
1010 Y=Y-1:PRINT"ASSEMBLING OUTPUT: ";P(Z);" ;PL =";Y;" "
1030 Y1=Y+NP:GOSUB 1720
1040 IF (FS=1 OR FR=1) AND INSTR(AL,")")<>0 THEN 1070
1050 IF FC=1 AND INSTR(AL,")")=0 THEN Y=Y+1:CN=CE+1:GOSUB 1720:GOTO 1350
1060 IF FC=1 THEN 1120 ELSE CN=CE+1:GOTO 1350
1070 GOSUB 2020:PRINT"EQUATION INVALID FOR THIS OUTPUT TYPE"
1080 PRINT"-->";A;" PIN =";ZO:END
1090 REM **********************************************************
1100 REM *** THREE-STATE ENABLE ONLY ***
1110 REM **********************************************************
1120 IF INSTR(AL,"VCC")<>0 THEN CN=CE+1:Y=Y+1:GOSUB 1720:GOTO 1350
1130 CN=INSTR(AL,"("):CT=INSTR(AL,")"):IF CN=0 OR CT=0 THEN 1070
1140 A=AL:CN=CN+1:CT=CT-1
1150 IF INSTR(A,"+")=0 THEN 1170
1160 GOSUB 2020:PRINT"INVALID CONDITIONAL STATEMENT":PRINT"-->";A:END
1170 DL="(:)+*":AT=""
1180 IF CN>CT THEN GOTO 1220
1190 P=MID$(A,CN,1):IF P=" " THEN CN=CN+1:GOTO 1180
1200 IF INSTR(DL,P)=0 THEN AT=AT+P:IF CN<>CT THEN CN=CN+1:GOTO 1180
1210 GOSUB 1560:GOTO 1170
1220 Y=Y+1:A=AA:CN=CE+1:CT=LEN(A)
1230 GOSUB 1720
1240 GOTO 1350
1250 REM **********************************************************
1260 REM *** INPUT PROCESSING FOR SIMPLE OUTPUTS ***
1270 REM **********************************************************
1280 LINE INPUT #1,A:IF EOF(1) THEN CLOSE:GOTO 2380
1290 IF INSTR(A,"DESCRIPTION")<>0 THEN 2380
1300 IF INSTR(A,"FUNCTION TABLE")<>0 THEN 2380
1310 ZZ=INSTR(A,";"):IF ZZ<>0 THEN A=LEFT$(A,ZZ-1)
1320 IF INSTR(A," ")=0 THEN 1340
1330 ZZ=INSTR(A," "):A=LEFT$(A,ZZ-1)+RIGHT$(A,LEN(A)-ZZ):GOTO 1320
1340 CT=LEN(A):CN=1:IF INSTR(A,"=")<>0 THEN 880
1350 AT="":P=MID$(A,CN,1):IF P<>"+" THEN 1370
1360 GOSUB 1560:Y=Y+1:GOSUB 1720:GOTO 1350
1370 IF P<>":" THEN 1390 ELSE IF MID$(A,CN,3)<>":+:" THEN 1390
1380 GOSUB 1560:CN=CN+2:Y=2*INT((Y+2)/2):GOSUB 1720:GOTO 1350
1390 IF P="*" THEN GOSUB 1560:GOTO 1350
1400 IF TY=7 AND (P="(" OR P=")") THEN 2040
1410 IF P="(" OR P=")" OR (P=":" AND TY<>15) THEN 1070
1420 CO=INSTR(CN,A,"+")
1430 CA=INSTR(CN,A,"*")
1440 IF CO>0 AND CA>0 AND CA>CO THEN CD=CO:GOTO 1480
1450 IF CO>0 AND CA=0 THEN CD=CO:GOTO 1480
1460 CD=CA
1470 IF CD=0 THEN CD=CT+1
1480 AT=MID$(A,CN,CD-CN):GOSUB 1560:CN=CD:IF CN=CO THEN Y=Y+1:GOSUB 1720
1490 CN=CD+1:IF CD>CT THEN 1280
1500 GOTO 1350
1510 GOSUB 2020:PRINT"EXCESSIVE NUMBER OF TERMS FOR THIS OUTPUT"
1520 PRINT"MAXIMUM NUMBER OF TERMS IS";NP;"FOR OUTPUT PIN";ZO:END
1530 REM **********************************************************
1540 REM *** INPUT MATCH AND SET FUSE ***
1550 REM **********************************************************
1560 IF AT="" THEN CN=CN+1:RETURN
1570 FOR Z=1 TO S+1
1580 IF AT=P(Z) THEN GOSUB 1670:X=X-1:GOTO 1640
1590 IF AT="/"+P(Z) THEN GOSUB 1670:GOTO 1640
1600 IF ASC(P(Z))=47 AND AT=MID$(P(Z),2) THEN GOSUB 1670:GOTO 1640
1610 NEXT
1620 IF LEFT$(AT,5)="CARRY" THEN 1280
1630 GOSUB 2020:PRINT"INPUT UNDEFINED BY PIN LIST":GOTO 1680
1640 F(X,Y)=0:NB=NB-1:CN=CN+1:RETURN
1650 GOSUB 2020:PRINT"EXCESSIVE NUMBER OF EQUATIONS GIVEN."
1660 PRINT"ONLY THE FIRST";NO;" WILL BE ASSEMBLED.":GOTO 2380
1670 X=N2(Z):IF X<>0 THEN RETURN ELSE GOSUB 2020:PRINT"INVALID INPUT PIN"
1680 PRINT"-->";A;" >";AT;"<":END
1690 REM **********************************************************
1700 REM *** INITZL PROD LINE WITH BLOWN FUSES ***
1710 REM **********************************************************
1720 IF Y>Y1 THEN 1510
1730 FOR I=0 TO XM:IF F(I,Y)=0 THEN F(I,Y)=1:NB=NB+1
1740 NEXT:RETURN
1910 Y=N(Z-12):NP=N1(Z-12):RETURN
2020 PRINT"*** ERROR ***":RETURN
2030 REM **********************************************************
2040 REM *** FOR 16A4 AND 16X4 PALS ONLY ***
2050 REM **********************************************************
2060 IF P=":"THEN A1=MID$(A,CN,3)ELSE GOTO 2100
2070 IF A1=":+:"THEN Y=4*(INT((Y+4)/4)):GOSUB 1720:CN=CN+3:GOTO 1390
2080 IF A1=":*:"THEN GOSUB 2020:PRINT"':*:' IS USED INSIDE PARENTHESES ONLY":END
2090 GOSUB 2020:PRINT">";P;"< IS INVALID AS USED IN:":PRINT"-->";A:END
2100 N8=CN:N9=INSTR(CN,A,")"):IF N9=0 THEN 2090
2110 A1=MID$(A,N8+1,N9-N8-1)
2120 N=VAL(RIGHT$(A1,1)):IF N<0 OR N>3 THEN 2130 ELSE 2140
2130 GOSUB 2020:PRINT"INVALID EXPRESSION '";A1;"'":END
2140 X=N*4+8
2150 N0=LEN(A1)-1:IF N0>6 THEN 2130
2160 ON N0 GOTO 2170,2190,2210,2220,2240,2290
2170 C=2:GOSUB 2340:IF MID$(A1,1,1)="A"THEN C=3 ELSE C=0
2180 GOSUB 2340:GOTO 2330
2190 C=1:GOSUB 2340:IF MID$(A1,2,1)="A"THEN C=0 ELSE C=3
2200 GOSUB 2340:GOTO 2330
2210 AT=A1:GOTO 1630
2220 C=2:GOSUB 2340:IF INSTR(A1,"+")<>0 THEN 2330
2230 C=0:GOSUB 2340:C=3:GOSUB 2340:GOTO 2330
2240 IF INSTR(A1,"+B")<>0 THEN C=0:GOSUB 2340:GOTO 2330
2250 IF INSTR(A1,"+/")<>0 THEN C=3:GOSUB 2340:GOTO 2330
2260 C=1:GOSUB 2340:C=2:GOSUB 2340
2270 IF INSTR(A1,"*B")<>0 THEN C=0:GOSUB 2340:GOTO 2330
2280 C=3:GOSUB 2340:GOTO 2330
2290 IF INSTR(A1,"+/")<>0 THEN C=1:GOSUB 2340:GOTO 2330
2300 IF INSTR(A1,"+:")<>0 THEN C=1:GOSUB 2340:C=2:GOSUB 2340:GOTO 2330
2310 C=0:GOSUB 2340:C=3:GOSUB 2340
2320 IF INSTR(A1,"*/")<>0 THEN C=1:GOSUB 2340:GOTO 2330
2330 CN=N9+1:GOTO 1350
2340 F(X+C,Y)=0:NB=NB-1:RETURN
2350 REM ****************************************************
2360 REM *** SAVE VARIABLES & CHAIN NEXT PRG. ***
2370 REM ****************************************************
2380 CLOSE
2382 FOR I=12 TO S
2384 IF N(I-12)<0 THEN N(I-12)=-N(I-12)
2386 IF N(I-12)>100 THEN N(I-12)=N(I-12)-100
2387 IF N(I-12)=0 THEN 2389
2388 N(I-12)=(N(I-12)-1)+N1(I-12)-1
2389 NEXT I
2390 OPEN "O",1,"PALTEMP.DAT"
2400 WRITE #1,TY,FCODE,TYPE$
2410 WRITE #1,NB,S,XM,YM,F$
2420 WRITE #1,OT$
2430 FOR J=0 TO YM
2440 A=""
2450 FOR I=0 TO XM STEP 2
2460 A=A+RIGHT$(STR$(F(I,J)),1)+RIGHT$(STR$(F(I+1,J)),1)
2470 NEXT I
2480 PRINT #1,A
2490 PRINT J;" ";CHR$(13);
2500 NEXT J
2510 FOR I=0 TO S-12
2520 WRITE #1,N(I),N1(I)
2530 NEXT I
2532 FOR I=1 TO S+1
2534 WRITE #1,P(I)
2536 NEXT I
2540 CLOSE
2550 RUN "PAL2"
2560 END
3000 C=0:FOR L1=1 TO INT((S/2)-1)
3010 RESTORE
3020 FOR L2=1 TO IX(L1)-1
3030 READ IN,IN,IN,IN,IN,IN,IN,IN
3040 NEXT L2
3050 FOR L2=1 TO 8
3060 READ IN
3070 ON IN GOSUB 3150,3200,3250,3300,3350,3400,3450
3075 C=C+1
3080 NEXT L2
3090 NEXT L1
3100 RETURN
3150 RETURN
3200 FOR I=0 TO XM
3210 F(I,C)=3
3220 NEXT I
3230 RETURN
3250 FOR I=0 TO XM
3260 F(I,C)=2
3270 NEXT I
3280 RETURN
3300 FOR I=6 TO XM-5 STEP 4
3310 F(I,C)=3:F(I+1,C)=3
3320 NEXT I
3330 RETURN
3350 FOR I=10 TO XM-9 STEP 4
3360 F(I,C)=3:F(I+1,C)=3
3370 NEXT I
3380 RETURN
3400 FOR I=14 TO XM-13 STEP 4
3410 F(I,C)=3:F(I+1,C)=3
3420 NEXT I
3430 RETURN
3450 FOR I=18 TO XM-17 STEP 4
3460 F(I,C)=3:F(I+1,C)=3
3470 NEXT I
3480 RETURN
5000 DATA 1,1,1,1,1,1,1,1
5010 DATA 2,2,2,2,2,2,2,2
5020 DATA 3,3,3,3,3,3,3,3
5030 DATA 4,4,3,3,3,3,3,3
5040 DATA 5,5,3,3,3,3,3,3
5050 DATA 5,5,5,5,3,3,3,3
5060 DATA 6,6,6,6,3,3,3,3
5070 DATA 6,6,3,3,3,3,3,3
5080 DATA 7,7,7,7,7,7,3,3
5090 DATA 7,7,7,7,3,3,3,3
5100 DATA 1,1,1,1,3,3,3,3
A